package AutoGen;

import DB.AttendanceDB;
import DB.SessionDB;
import DB.StudentDB;
import Model.Attendance;
import Model.Session;
import Model.Student;
import org.junit.Test;

import java.util.ArrayList;

public class AttendanceGen {

    public AttendanceGen() {
    }

    /**
     * Generates attendance for all students
     */
    @Test
    public void attendanceGen() {

        SessionDB sessionDB = new SessionDB();
        ArrayList<Session> sessionList = sessionDB.getAllSessions(false);
        StudentDB studentDB = new StudentDB();
        ArrayList<Student> studentList = studentDB.getAllStudents(false);
        AttendanceDB attendanceDB = new AttendanceDB();

        int id = 1;

        for (Session s : sessionList) {

            for (Student st : studentList) {

                if (s.getTeamId().getId() == st.getTeamId().getId()) {
                    Attendance attendance = new Attendance();

                    attendance.setId(id);
                    attendance.setComment("");
                    attendance.setIsAttending(false);
                    attendance.setStudentId(st);
                    attendance.setSessionId(s);

                    System.out.println(attendance);

                    attendanceDB.insertAttendance(attendance);

                    id++;
                }
            }
        }
    }
}
